<template>
    <div>
        <!-- 搜索 -->
        <el-form :inline="true" ref="params" size="small" :model="params" class="demo-form-inline" @submit.native.prevent>
            <!-- <el-form-item label="标题">
                <el-input @keyup.enter.native="onSubmit" v-model="params.headline" clearable placeholder="标题"></el-input>
            </el-form-item> -->
            <el-form-item label="联合体分类">
                <el-select v-model="params.allianceType" placeholder="联合体分类">
                    <el-option label="创新联合体" value="0"></el-option>
                    <el-option label="产教联合体" value="1"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="审核状态">
                <el-select v-model="params.status" placeholder="审核状态">
                    <el-option label="待审核" value="0"></el-option>
                    <el-option label="审核通过" value="1"></el-option>
                    <el-option label="审核驳回" value="2"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
                <el-button @click="onReset">重置</el-button>
            </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="tableData" style="width: 100%" :header-cell-style="{ background: '#f0f2f5' }"
            >
            <el-table-column label="序号" width="48" type="index"></el-table-column>
            <el-table-column prop="name" label="姓名/机构名称" show-overflow-tooltip width="150">
            </el-table-column>
            <el-table-column prop="allianceType" label="联盟分类">
                <template slot-scope="scope">
                    <span v-if="scope.row.allianceType === '0'">创新联合体</span>
                    <span v-if="scope.row.allianceType === '1'">产教联合体</span>
                </template>
            </el-table-column>
            <el-table-column prop="contactPerson" label="联系方式" show-overflow-tooltip width="160">
            </el-table-column>
            <el-table-column prop="status" label="审核状态">
                <template slot-scope="scope">
                    <span v-if="scope.row.status === '0'">待审核</span>
                    <span v-if="scope.row.status === '1'">审核通过</span>
                    <span v-if="scope.row.status === '2'">审核驳回</span>
                </template>
            </el-table-column>
            <el-table-column prop="createTime" label="创建时间" width="170" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="updateTime" label="更新时间" width="170" show-overflow-tooltip>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="100">
                <template slot-scope="scope">
                    <el-button @click="handleDetail(scope.row.id)" type="text" size="small">查看详情</el-button>
                    <!-- <el-button @click="handleEdit('edit',scope.row.id)" type="text" size="small">编辑</el-button> -->
                </template>
            </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div class="poolPage">
            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="params.page" :page-sizes="[10, 20, 30]" :page-size="params.pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
        </div>
        <!-- 详情 -->
        <ApplyDetail ref="detailContent"/>
        <!-- 编辑 -->
        <!-- <FormDialog ref="formContent"/> -->
    </div>
</template>
<script>
import { eduApplyList } from "@/request/api/education"
import ApplyDetail from "./applyDetail.vue"
export default {
    components: {
        ApplyDetail
    },
    data() {
        return {
            multipleSelection: [],//批量选择
            loading: true,
            tableData: [],
            params: {
                // headline: '',//标题
                // supplyDemand: '',//类型（0需求 1供应）
                page: 1,
                pageSize: 10,
                createBy: '',//申请人id
            },
            total: 0,
            imgUrl: ''
        }
    },
    created() {
        this.getResoure()
    },
    methods: {
        // 获取列表
        getResoure() {
            var userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"));
            this.params.createBy = userInfo.id
            eduApplyList(this.params).then(res => {
                this.loading = false
                if (res.data.code === 200) {
                    console.log(res,'123')
                    this.tableData = res.data.result.items
                    this.total = res.data.result.total
                }
            })
        },
        // 搜索
        onSubmit() {
            this.params.page = 1;
            this.getResoure();
        },
        // 重置
        onReset() {
            let params = {
                page: 1,
                pageSize: 10
            }
            this.params = params
            this.getResoure();
        },
        handleSizeChange(val) {
            this.params.pageSize = val;
            this.params.page = 1;
            this.getResoure();
        },
        handleCurrentChange(val) {
            this.params.page = val;
            this.getResoure();
        },
        // 新增产品
        handleAdd(type, data) {
            this.$refs.formContent.open(type, data)
        },
        // 编辑产品
        handleEdit(type, data) {
            this.$refs.formContent.open(type, data)
        },
        // 删除
        hanldeDelete(id) {
            this.$confirm("确定删除吗?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            }).then(() => {
                resourceDelete(id).then((res) => {
                    if (res.data.code === 200) {
                        this.$message({
                            message: res.data.message,
                            type: "success",
                        });
                        this.getResoure()
                        this.$refs.tableRef.clearSelection();

                    } else {
                        this.$message.error(res.data.message);
                    }
                });
            })
        },
        // 选择左侧复选框
        changeSelect(val) {
            this.multipleSelection = val;
        },
        getKey(row) {
            return row.id;
        },
        // 批量删除
        batchDelete() {
            if (this.multipleSelection.length === 0) {
                this.$message({
                    message: '请选择数据！',
                    type: 'warning'
                });
                return false;
            }
            this.$confirm("确定删除吗?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            }).then(() => {
                var ids = this.multipleSelection.map(item => item.id)
                this.hanldeDelete(ids)
            })
        },
        // 查看详情
        handleDetail(id) {
            this.$refs.detailContent.open(id)
        },
    }
}
</script>
<style lang="less" scoped>
.poolPage {
    margin-top: 15px;
    text-align: right;
}
</style>

